/*  This file is part of CASpp.

    CASpp is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    CASpp is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with CASpp.  If not, see <http://www.gnu.org/licenses/>.

    Copyright 2014 Jérome LAURENS

    See https://code.google.com/p/idalgo/

*/

#if !defined CASPP_MODELS_BOOLEAN_H
#define CASPP_MODELS_BOOLEAN_H

#include <string>
#include <boost/smart_ptr.hpp>
#include <caspp/config.h>

CASPP_NS_BEGIN

class Boolean;

typedef boost::shared_ptr<Boolean> BooleanRef;

class Boolean {
public:
    enum Values {
        kUndefined = 0,
        kTrue = 1,
        kFalse = 2,
        kUnknown = 4
    };
    Boolean(const Values v);
    Boolean(const bool yorn);
    Boolean(const std::string & s);
    Boolean(const char * s);

    bool isTrue() const;
    bool isFalse() const;
    bool isUnknown() const;
    bool isUndefined() const;

    Boolean operator ! () const;
    Boolean operator && (const Boolean & rhs) const;
    Boolean operator && (const bool & rhs) const;
    Boolean operator || (const Boolean & rhs) const;
    Boolean operator || (const bool & rhs) const;

    std::string description() const;

    Values value() const;

private:
    Values value_m;
    void init(const std::string & s);
};

bool isTrue(const Boolean & b);
bool isFalse(const Boolean & b);
bool isUnknown(const Boolean & b);
bool isUndefined(const Boolean & b);

CASPP_NS_END

CASpp::Boolean operator && (const bool & lhs, const CASpp::Boolean & rhs);
CASpp::Boolean operator || (const bool & lhs, const CASpp::Boolean & rhs);


#endif // CASPP_MODELS_BOOLEAN_H
